<!-- 加载layout.html -->
{{extend('./layout.html')}}
			
{{#block('main')}}			
	<div class="main-container">
		<div class="padding-md">
			<h2 class="header-text">
				修改学生
				<span class="sub-header">
					add class
				</span>
			</h2>
			<div class="smart-widget m-top-lg widget-dark-blue">
				<div class="smart-widget-header">
					请填写学生信息
					<span class="smart-widget-option">
						<span class="refresh-icon-animated">
							<i class="fa fa-circle-o-notch fa-spin"></i>
						</span>
                        <a href="#" class="widget-toggle-hidden-option">
                            <i class="fa fa-cog"></i>
                        </a>
                        <a href="#" class="widget-collapse-option" data-toggle="collapse">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a href="#" class="widget-refresh-option">
                            <i class="fa fa-refresh"></i>
                        </a>
                        <a href="#" class="widget-remove-option">
                            <i class="fa fa-times"></i>
                        </a>
                    </span>
				</div>
				<div class="smart-widget-inner">
					<div class="smart-widget-hidden-section">
						<ul class="widget-color-list clearfix">
							<li style="background-color:#20232b;" data-color="widget-dark"></li>
							<li style="background-color:#4c5f70;" data-color="widget-dark-blue"></li>
							<li style="background-color:#23b7e5;" data-color="widget-blue"></li>
							<li style="background-color:#2baab1;" data-color="widget-green"></li>
							<li style="background-color:#edbc6c;" data-color="widget-yellow"></li>
							<li style="background-color:#fbc852;" data-color="widget-orange"></li>
							<li style="background-color:#e36159;" data-color="widget-red"></li>
							<li style="background-color:#7266ba;" data-color="widget-purple"></li>
							<li style="background-color:#f5f5f5;" data-color="widget-light-grey"></li>
							<li style="background-color:#fff;" data-color="reset"></li>
						</ul>
					</div>
					<div class="smart-widget-body">
						<form action="" method="post" enctype="multipart/form-data">
							<div class="form-group">
								<label>选择班级</label>
								<select class="form-control" name="class_id" required>
									<option value="">请选择</option>
									{{#each(clsList)}}
									<option value="{{this.class_id}}" {{this.class_id===stuData.class_id?'selected':''}}>{{this.class_name}}</option>
									{{/each}}
								</select>	
							</div><!-- /form-group -->
							<div class="form-group">
								<label for="exampleInputEmail1">学生姓名</label>
								<input type="text" class="form-control" id="exampleInputEmail1" placeholder="请输入学生姓名" name="stu_name" value="{{stuData.stu_name}}" required>
							</div><!-- /form-group -->
							<div class="form-group">
								<label for="exampleInputEmail2">学生年龄</label>
								<input type="text" class="form-control" id="exampleInputEmail2" placeholder="请输入学生年龄" name="stu_age" value="{{stuData.stu_age}}" required>
							</div><!-- /form-group -->
							<div class="form-group">
								<label for="exampleInputEmail3">手机号码</label>
								<input type="text" class="form-control" id="exampleInputEmail3" placeholder="请输入手机号码" name="stu_phone" value="{{stuData.stu_phone}}" required>
							</div><!-- /form-group -->
							<div class="form-group">
								<label>选择性别</label>
								<div class="col-lg-12">
									<div class="radio inline-block">
										<div class="custom-radio m-right-xs">
											<input type="radio" id="inlineRadio1" name="stu_sex" value="0" {{stuData.stu_sex===0?'checked':''}}>
											<label for="inlineRadio1"></label>
										</div>
										<div class="inline-block vertical-top">女</div>
									</div>
									<div class="radio inline-block">
										<div class="custom-radio m-right-xs">
											<input type="radio" id="inlineRadio2" name="stu_sex" value="1" {{stuData.stu_sex===1?'checked':''}}>
											<label for="inlineRadio2"></label>
										</div>
										<div class="inline-block vertical-top">男</div>
									</div>
								</div><!-- /.col -->
							</div><!-- /form-group -->
							<div class="form-group">
								<label>报名时间</label>
								<div class="input-group">
									<input class="datetimepicker-input form-control" data-date-format="YYYY-MM-DD" name="stu_time" type="text" value="{{stuData.stu_time}}" required/>
									<span class="input-group-addon"><i class="fa fa-clock-o"></i></span>
								</div>
							</div><!-- /form-group -->
							<div class="form-group">
								<label>上传头像</label>
								<div class="col-lg-12 input-group">
									<img src="/uploads/{{stuData.stu_img}}" alt="" style="width: 120px;">
									<input type="file" class="form-control" name="stu_img">
								</div><!-- /.col -->
							</div><!-- /form-group -->
							<div class="form-group">
								<label>选择学科</label>
								{{#each(subList)}}
								<div class="checkbox inline-block">
									<div class="custom-checkbox">
										<input type="checkbox" id="inlineCheckbox{{xindex}}"  name="sub[]" value="{{this.sub_id}}" >
										<!-- 复选框的name写成数组 -->
										<label for="inlineCheckbox{{xindex}}"></label>
									</div>
									<div class="inline-block vertical-top">
										{{this.sub_name}}
									</div>
								</div>
								{{/each}}
								{{#each(sub)}}
								<span index='{{xindex}}' sub='{{this}}'></span>
								{{/each}}
								<span lenSub='{{sub.length}}' lenList='{{subList.length}}' id="length"></span>
							</div><!-- /form-group -->

							<button type="submit" class="btn btn-success btn-sm">提交</button>
						</form>
					</div>
				</div><!-- ./smart-widget-inner -->
			</div><!-- ./smart-widget -->

	
		</div>
	</div><!-- ./smart-widget-inner -->
{{/block}}
<script>
$(function()	{
	for(var i =0 ; i<=$('#length').attr('lenSub');i++){
		for(var j=0 ; j<=$('#length').attr('lenList');j++){
			if($('#inlineCheckbox'+j+'').val()==$('span[index="'+i+'"]').attr('sub')){
				$('#inlineCheckbox'+j+'').attr('checked','checked');
			}
		}
	}	
})
</script>